When a connection blocked waiting on a transaction, don't queue watch events.
Sure, they'd be ignored and re-transmitted, but it hits an assert that we don't
send data out blocked connections, and it's wasteful.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
--- /dev/null
+# Test case where blocked connection gets sent watch.
+
+mkdir /test
+watch /test token
+1 start /test
+# This will block on above
+noackwrite /test/entry create contents
+1 write /test/entry2 create contents
+1 commit
+readack
+expect /test/entry2:token
+waitwatch
+ackwatch token
else
continue;
/* If connection not doing anything, queue this. */
- if (!i->out)
+ if (i->state == OK)
queue_next_event(i);
}
}
static void do_readack(unsigned int handle)
{
enum xsd_sockmsg_type type;
- char *ret;
-
- ret = read_reply(handles[handle]->fd, &type, NULL);
- if (!ret)
- failed(handle);
- free(ret);
+ char *ret = NULL;
+
+ /* Watches can have fired before reply comes: daemon detects
+ * and re-transmits, so we can ignore this. */
+ do {
+ free(ret);
+ ret = read_reply(handles[handle]->fd, &type, NULL);
+ if (!ret)
+ failed(handle);
+ } while (type == XS_WATCH_EVENT);
}
static void do_setid(unsigned int handle, char *id)